﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tww.AppToolkit.AppInfrastructure.Interfaces.ViewModels;
using Tww.Pixxler.PixxlerAppInfrastructure.Interfaces.ViewModels;
using Tww.Pixxler.PixxlerAppInfrastructure.Interfaces.Views;

namespace Tww.Pixxler.WPFPixxlerPictureEditorModule.Views
{
    /// <summary>
    /// Interaktionslogik für PictureEditorView.xaml
    /// </summary>
    public partial class PictureEditorView : UserControl, IPictureEditorView
    {
        public PictureEditorView( IPictureEditorViewModel viewModel )
        {
            InitializeComponent();
            this.ContentViewModel = viewModel;
        }

        public IContentViewModel ContentViewModel
        {
            get
            {
                return this.DataContext as IContentViewModel;
            }
            set
            {
                this.DataContext = value;
            }
        }

        public void Cleanup()
        {
            if ( !this.IsCleanedup )
            {
                if ( this.ContentViewModel != null )
                {
                    this.ContentViewModel.Cleanup();
                    this.ContentViewModel = null;
                }
                this.IsCleanedup = true;
            }
        }

        public bool IsCleanedup
        {
            get;
            private set;
        }
    }
}
